import { useResponseSuccess } from '~/utils/response';

export default eventHandler((event) => {
  const query = getQuery(event);
  const serviceId = query.serviceId as string;
  const date = query.date as string;

  // 生成当天的时间段
  const generateTimeSlots = () => {
    const slots = [];
    const startHour = 9; // 9点开始
    const endHour = 21; // 21点结束
    const interval = 30; // 30分钟一个时段

    for (let hour = startHour; hour < endHour; hour++) {
      for (let minute = 0; minute < 60; minute += interval) {
        const time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
        slots.push({
          id: `${hour}_${minute}`,
          time,
          available: Math.random() > 0.3, // 70%概率可用
          remainingCapacity: Math.floor(Math.random() * 5) + 1, // 1-5个剩余容量
        });
      }
    }
    return slots;
  };

  const timeSlots = generateTimeSlots();

  return useResponseSuccess(timeSlots);
});
